const http = require('http')
const url = require('url')
const fs = require('fs')

const server = http.createServer((req, res) => {
    fs.readdir('./file', (err, files) => {
        let dirctory = [];
        (function iterator(i) {
            if (i == files.length) {
                return console.log(dirctory)
            }
            fs.stat('./file/' + files[i], (err, stats) => {
                stats.isDirectory() ? dirctory.push(files[i]) : null
                iterator(++i)
            })
        })(0)

    })
})

server.listen(3000)